package panel.downloadZipPanel
{
	import assists.ButtonUtils;
	import assists.HtmlText;
	import assists.Lang;
	import assists.TextFieldUtils;
	import assists.URI;
	import assists.resource.ResourceLoader;
	
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	public class FullBtnBox extends Sprite
	{
		private var _stage:Stage;
		private var _loader:ResourceLoader;
		private var _lang:Lang;
		private var _uri:URI;
		
		private var back:Bitmap;
		private var backContainer:Sprite;
		
		private var text:TextField;
		
		private var btn:ButtonUtils;
		
		public function FullBtnBox(stage:Stage, loader:ResourceLoader, lang:Lang, uri:URI)
		{
			_stage = stage;
			_loader = loader;
			_lang = lang;
			_uri = uri;
			
			initThis();
		}
		
		private function initThis():void
		{
			backContainer = new Sprite;
			this.addChild(backContainer);
			back = new _loader.uiManager.componentBack as Bitmap;
			back.width = _stage.stageWidth;
			back.height = _stage.stageHeight * .1;
			backContainer.addChild(back);
			
			text = new TextField;
			text.wordWrap = false;
			text.multiline = false;
			text.mouseEnabled = false;
			text.autoSize = TextFieldAutoSize.LEFT;
			this.addChild(text);
		}
		
		public function changeData(type:int,func:Function,str:String):void
		{
			if(type == 1){
				
				var smallText:TextField = new TextField();
				smallText.wordWrap = false;
				smallText.multiline = false;
				smallText.mouseEnabled = false;
				TextFieldUtils.setHtmlText(smallText,HtmlText.formatSizeColor("<b>点击</b>",0x000000,18));
				smallText.width = smallText.textWidth + 5;
				smallText.height = smallText.textHeight + 5;
				this.addChild(smallText);
				smallText.y = _stage.stageHeight * .03;
				
				var icon:Bitmap = new _loader.uiManager.downloadIcon as Bitmap;
				icon.smoothing = true;
				icon.width = _stage.stageHeight * .05;
				icon.height = _stage.stageHeight * .05;
				icon.x = _stage.stageWidth * .22;
				icon.y = _stage.stageHeight * .02;
				this.addChild(icon);
				
				smallText.x = icon.x - smallText.width;;
				
				TextFieldUtils.setHtmlText(text,HtmlText.formatSizeColor("<b>" + str + "</b>",0x000000,18));
				text.width = text.textWidth + 5;
				text.height = text.textHeight + 5;
				text.x = _stage.stageWidth * .3;
				text.y = _stage.stageHeight * .03;
				
			}else{
				var backImg:Bitmap = new _loader.uiManager.arrowIcon as Bitmap;
				backImg.height = _stage.stageWidth * .1;
				backImg.width = _stage.stageWidth * .1;
				backImg.x = backImg.width;
				backImg.smoothing = true;
				backImg.rotationY = 180;
				
				btn = new ButtonUtils(backImg,func);
				btn.x = _stage.stageWidth * .08;
				btn.y = _stage.stageHeight * .02;
				this.addChild(btn);
				
				TextFieldUtils.setHtmlText(text,HtmlText.formatSizeColor("<b>" + str + "</b>",0x000000,18));
				text.width = text.textWidth + 5;
				text.height = text.textHeight + 5;
				text.x = _stage.stageWidth * .2;
				text.y = _stage.stageHeight * .03;
			}
		}
		
		public function clear():void
		{
			if(_stage){
				_stage = null;
				_loader = null;
				_lang = null;
				_uri = null;
				
				if(btn){
					btn.clearThis();
					back = null;
				}
				
				backContainer = null;
			}
		}
	}
}